#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include "dominion/dominion.h"
#include "dominion/dominion_helpers.h"
#include "dominion/rngs.h"
#include "dominion/interface.h"

/* testing smithy card*/

int cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus);

int main (int argc, char * argv[])
{
	/*modified from the initialization in the provided testUpdateCoins.c file */
    int seed = 1000;
    int numPlayer = 2;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
	int r;
	int bonus = 0;
	
	/* test one -- to see if 3 cards have been added to hand */
	struct gameState test_one;
    memset(&test_one, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &test_one); // initialize a new game
	
	test_one.whoseTurn = 0;
	test_one.hand[0][0] = smithy;
	int handcount = test_one.handCount[0];
	
	cardEffect(smithy, 0, 0, 0, &test_one, 0, &bonus);
	
	if (test_one.handCount[0] == handcount + 2) //smithy card is discarded, 3 cards added, so (+ 3, - 1) = 2
		printf("Smithy test: PASS when testing to see if 3 cards have been added to hand. \n");
	else
		printf("Smithy test: FAIL when testing to see if 3 cards have been added to hand. \n");
		
	/* test two -- to see if 3 cards are added when deck count is 0 */
	struct gameState test_two;
    memset(&test_two, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &test_two); // initialize a new game
	
	test_two.whoseTurn = 0;
	test_two.hand[0][0] = smithy;
	test_two.deckCount[0] = 0;
	handcount = test_two.handCount[0];
	
	cardEffect(smithy, 0, 0, 0, &test_two, 0, &bonus);
	
	if (test_one.handCount[0] == handcount + 2) //smithy card is discarded, 3 cards added, so (+ 3, - 1) = 2
		printf("Smithy test: PASS when testing to see if 3 cards have been added to hand when deck count is 0. \n");
	else
		printf("Smithy test: FAIL when testing to see if 3 cards have been added to hand when deck count is 0. \n");
	
	return 0;
}